#ifndef COOLPOOL_SIMULATION_COLLISIONTIMEFINDER_H_
#define COOLPOOL_SIMULATION_COLLISIONTIMEFINDER_H_

#include <assert.h>

#include "Constants.h"
#include "Collision.h"
#include "CollisionDetector.h"
#include "DynamicEntity.h"

namespace coolpool
{
	// Base class for all collision time finder of objects which is used in the collision
	// detection engine.
	class CollisionTimeFinder
	{
	public:

		// Every custom collision detection time finder should override this method
		// in order to sort out the different types of entities. For every type of entity
		// findCollisionTimeWithDetectorStatic or findCollisionTimeWithDetectorDynamic should be used.
		virtual const Collision * findCollisionTime(DynamicEntity * dynamic_entity, Entity * entity, double time_step, double lambda)
			throw (UnexpectedInputException)= 0;

	protected:
		CollisionTimeFinder();

		// Finds the collision time between dynamic and static entity by the correct CollisionDetector.
		// The time is added to the Collision->time member.
		// If a wrong CollisionDetector is passed it should throw exception.
		const Collision * findCollisionTimeWithDetectorStatic(const CollisionDetector & collision_detector, DynamicEntity * dynamic_entity, Entity * entity, double time_step, double lambda)
				throw (UnexpectedInputException);

		// Finds the collision time between  two dynamic entities by the correct CollisionDetector.
		// The time is added to the Collision->time member.
		// If a wrong CollisionDetector is passed it should throw exception.
		const Collision * findCollisionTimeWithDetectorDynamic(const CollisionDetector & collision_detector, DynamicEntity * dynamic_entity1, DynamicEntity * dynamic_entity2, double time_step, double lambda)
				throw (UnexpectedInputException);
	};
}

#endif
